1. Field of the Invention
The present invention relates to an image processing method for carrying out image processing by changing the coefficients of the spatial frequency components of image data, an image processing apparatus for carrying out such an image processing method, an image forming apparatus including such an image processing apparatus, a computer program product for operating a general purpose computer so as to function as the above-mentioned image processing apparatus, and a computer program product on which a computer program has been recorded.
2. Description of Related Art
As a method for decreasing the number of gray levels of an image including halftones, for example, as a method for binarizing an image having 256 gray levels to obtain an image having 2 gray levels, a method for carrying out binarization by comparing the number of gray levels of an image with a predetermined value, i.e., a threshold value, a dither method and an error diffusion method (Japanese Patent Application Laid-Opens No. 2000-299783, No. H06-189119 (1994) and No. 2002-10085) are known.
FIG. 1 is a schematic view showing an example of a dither matrix of 4×4 that is used in the case where an image having 16 gray level is binarized in the conventional dither method. In the dither matrix, any one of predetermined values in the range of 0 to 240 is set according to the location of the pixel. In the dither method, the number of gray levels of image data having 16 gray level having been inputted are compared with the predetermined values having been set in the dither matrix, pixel by pixel. In the case where the number of gray levels of the image data is equal to or more than the predetermined value, the gray level is set at 255, and in the case where the gray level is less than the predetermined value, the gray level is set at 0. In this way, the image is binarized.
In the error diffusion method, a quantization error occurring when each pixel of image data having been inputted is binarized, that is, the difference between the gray level of a pixel before binarization and the gray level after binarization is diffused to pixels not yet binarized. In the case where a pixel to be binarized is assumed to be a processing pixel, the quantization error of the processing pixel is added to the gray levels of the pixels not yet binarized and located in the vicinity of the processing pixel, after weighting is carried out according to the relative location from the processing pixel.
FIG. 2 is a schematic view showing an example of a weighting coefficient matrix being used in the conventional error diffusion method. In the example shown in FIG. 2, a weighting coefficient matrix of 3×2 including a processing pixel (IX, IY) is shown, wherein the horizontal direction (the left-right direction in FIG. 2) is assumed to be the X direction, and the vertical direction (the up-down direction in FIG. 2) is assumed to be the Y direction. The weighting coefficient matrix has the weighting coefficients of the lower left pixel, the lower pixel, the lower right pixel and the right pixel adjacent to the processing pixel (IX, IY). For example, the gray level of the processing pixel (IX, IY) is compared with a predetermined value. In the case where the gray level is equal to or more than the predetermined value, the gray level of the processing pixel (IX, IY) is set at 255. In the case where the gray level is less than the predetermined value, the gray level of the processing pixel (IX, IY) is set at 0. Next, the difference between the binarized gray level, 255 or 0, and the gray level of the processing pixel (IX, IY) before binarization, that is, a quantization error, is diffused to the adjacent pixels before binarization, on the basis of the weighting coefficient matrix. However, since the left pixel (IX−1, Y) adjacent to the processing pixel (IX, IY) has already been quantized earlier than the processing pixel (IX, IY), the quantization error is not diffused to the left pixel.
In the case where the quantization error is assumed to be Err, Err×( 7/16), Err×( 1/16) and Err×( 5/16), Err×( 3/16) are diffused to the four pixels (IX+1, IY), (IX+1, IY+1), (IX, IY+1) and (IX−1, IY+1) adjacent to the processing pixel (IX, IY), respectively.
In the error diffusion method, since the quantization error is diffused to the adjacent unprocessed pixels on the basis of the weighting coefficient matrix, the method has an advantage of hardly causing moire patterns in binarized images in comparison with the dither method.
In addition, in the method disclosed in Japanese Patent Application Laid-Open No. 2002-10085, image data is converted to image data having spatial frequency components, and halftone processing of the image is carried out by using the data converted to halftone spatial frequency domains predetermined for the coefficients of the spatial frequency components used for the transformation.
In the dither method, however, since binarization is carried out by using the dither matrix having the same pattern, there is a problem of generating texture peculiar to the dither method, that is, periodic patterns, in a binarized image.
Furthermore, in the error diffusion method, since an error is diffused for each pixel on the basis of the same matrix, a large quantization error is diffused in a chain reaction at a highlight area having large gray levels. This causes a problem of connecting pixels to one another. More specifically, pixels having different gray levels are forced to have the same gray level, and this causes a problem of generating an image having pixels partly connected to one another.
Still further, since predetermined halftone data is used in the invention disclosed in Japanese Patent Application Laid-Open No. 2002-10085, there is a problem of generating texture or the like as in the case of the error diffusion method or the dither method. In other words, a problem similar to that described above occurs since halftone processing is merely carried out in frequency domains by using a method similar to the above-mentioned conventional method.